﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;              //命名空间
using System.Data.SqlClient;    //数据库头文件
using System.Data.Sql;         //数据库头文件
using DATA_operate_;          //自定义数据库操作类引用
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    DATA_operate data_operate_in_myinfo = new DATA_operate();   //创建数据库操作类对象
   
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        string adminname = data_operate_in_myinfo.dataread("_student", "_Sname", "_Sid", str_sid);
        Label1.Text = "欢迎您" + adminname + "同学";



        string backgroudtype = data_operate_in_myinfo.dataread("_student", "_Sbackgroud", "_Sid", str_sid);


        /*
        //修改head标签中的title标签属性
        Page.Header.Title = "编程改变内容页标题";
        //修改head标签包含的其它标签属性，间接修改了页面背景颜色
        Style myStyle = new Style();
        myStyle.BackColor = System.Drawing.Color.Red;
        Page.Header.StyleSheet.CreateStyleRule(myStyle, null, "html");
        //添加新标签meta到head标签中
        HtmlMeta metaKeywords = new HtmlMeta();
        metaKeywords.Name = "KEYWORDS";
        metaKeywords.Content = "asp.net,c#";
        HtmlHead head = Page.Header;
        head.Controls.Add(metaKeywords);
        */

        // KS.Attributes.Add("background", Page.Request.ApplicationPath.ToString() + "/image/background/landingbg1.png");
        backgroudtype = backgroudtype.Replace(" ", "");

        Page.IsStartupScriptRegistered("b");
        switch (backgroudtype)
        {
            case "1":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/1.jpg'</script>");
                break;
            case "2":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/2.jpg'</script>");
                break;
            case "3":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/3.jpg'</script>");
                break;
            case "4":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/4.jpg'</script>");
                break;
            case "5":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/5.jpg'</script>");
                break;
            case "6":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/6.jpg'</script>");
                break;
            case "7":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/7.jpg'</script>");
                break;
            case "8":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/8.jpg'</script>");
                break;
            case "9":
                Page.RegisterStartupScript("b", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/9.jpg'</script>");
                break;
            default:
                break;

        }


        Random ran = new Random();
        int RandKey = ran.Next(1, 24);
        string choose = "" + RandKey;
        string path = "~/image/face/" + choose + ".png";
        Image1.ImageUrl = path;
    }



    protected void buttom1(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b1"))
            Page.RegisterStartupScript("b1", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/1.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "1", "_Sid", str_sid);
    }

    protected void buttom2(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b2"))
            Page.RegisterStartupScript("b2", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/2.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "2", "_Sid", str_sid);
    }

    protected void buttom3(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b3"))
            Page.RegisterStartupScript("b3", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/3.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "3", "_Sid", str_sid);
    }
    protected void buttom4(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b4"))
            Page.RegisterStartupScript("b4", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/4.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "4", "_Sid", str_sid);
    }

    protected void buttom5(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b5"))
            Page.RegisterStartupScript("b5", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/5.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "5", "_Sid", str_sid);
    }

    protected void buttom6(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b6"))
            Page.RegisterStartupScript("b6", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/6.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "6", "_Sid", str_sid);
    }

    protected void buttom7(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b7"))
            Page.RegisterStartupScript("b7", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/7.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "7", "_Sid", str_sid);


    }
    protected void buttom8(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b8"))
            Page.RegisterStartupScript("b8", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/8.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "8", "_Sid", str_sid);

    }
    protected void buttom9(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["stuid"];
        string str_sid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("b9"))
            Page.RegisterStartupScript("b9", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/9.jpg'</script>");
        data_operate_in_myinfo.Data_update("_student", "_Sbackgroud", "9", "_Sid", str_sid);
    }


    protected void ImageButton10_Click(object sender, ImageClickEventArgs e)   //链接1   百度首页
    {
        Response.Write("<script>window.location='http://www.baidu.com'</script>");
    }
    protected void ImageButton11_Click(object sender, ImageClickEventArgs e) //链接2   有意思吧首页
    {
        Response.Write("<script>window.location='http://www.u148.net/'</script>");
    }
    protected void ImageButton12_Click(object sender, ImageClickEventArgs e) //链接2   songtaste首页
    {
        Response.Write("<script>window.location='http://www.songtaste.com/'</script>");
    }


}
